package com.liuyjy.base.common.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @Author liuyjy
 * @Date 2022/2/7 11:16
 * @Description: 分页参数
 **/
//@ApiModel(description = "分页查询数据封装对象", value = "分页查询数据封装对象")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class PageSearch implements Serializable {

    //@NotNull(message = "page is null ！")
    @ApiModelProperty(value = "当前页数", name = "page")
    protected Integer page = 1;

    //@NotNull(message = "limit is null ！")
    @ApiModelProperty(value = "每页查询条数", name = "limit")
    protected Integer limit = 10;

    @ApiModelProperty(value = "是否查询总数（默认为否）", name = "searchCount")
    protected boolean searchCount;

//    @ApiModelProperty(value = "总数(提前明确总条数时使用)", name = "total", required = true)
//    protected long total = 0;

    public <T> Page<T> getPages(Class<T> clazz) {
        return new Page<T>(page, limit, searchCount);
    }


}
